<html>
<head>
  <meta charset="utf-8">
  <title>files-h5</title>
</head>
<body>
  
  <img src="" id="portrait1" style="width: 200px; height: 200px; display: block;" />
  <input type="file" id="file" onchange="showPreview(this, 'portrait1')" />

  <img src="" id="portrait2" style="width: 200px; height: 200px; display: block;" />
  <input type="file" id="file" onchange="showPreview(this, 'portrait2')" />
  <script>
  function showPreview(source, imgId) {
    var file = source.files[0];
    if(window.FileReader) {
      var fr = new FileReader();
      fr.onloadend = function(e) {
        document.getElementById(imgId).src = e.target.result;
      }
      fr.readAsDataURL(file);
    }
  }
  </script>
</body>
</html>